package cn.kgc.ssm.web.controller;

import cn.kgc.ssm.web.entity.Member;
import cn.kgc.ssm.web.response.ResponseResult;
import cn.kgc.ssm.web.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @author 课工场
 * @date 2024/7/31
 * @description 会员管理模块
 */
@RestController
@RequestMapping("member")
public class MemberController {

    @Autowired
    private MemberService memberService;
    // 分页
    @GetMapping("page")
    public ResponseResult memberPage(Integer page,Integer limit,String memberName,String level) {
        return  memberService.memberPage(page,limit,memberName,level);
    }


    // 添加会员
    @PostMapping("add")
    public ResponseResult addMember(Member member) {
        return  memberService.addMember(member);
    }

    // 编辑会员
    @PostMapping("edit")
    public ResponseResult editMember(Member member) {
        return  memberService.editMember(member);
    }


    // 删除会员
    @PostMapping("delete")
    public ResponseResult deleteMember(Integer[] ids) {
        return  memberService.deleteMember(ids);
    }

    // 重置会员密码
    @PostMapping("resetPassword")
    public ResponseResult resetPassword(Integer id) {
        return  memberService.resetPassword(id);
    }


    // 会员注册
    @PostMapping("/font/register")
    public ResponseResult register(Member member) {
        return  memberService.registerMember(member);
    }

    // 会员登录
    @PostMapping("/font/login")
    public ResponseResult login(String memberName, String password, HttpSession session) {
        return  memberService.login(memberName,password,session);
    }

}
